<!DOCTYPE html>
<html>
<head>
    <title>ThePornDB</title>
</head>
<body>
    <div id="ThePornDBConfigurationPage" data-role="page" class="page type-interior pluginConfigurationPage" data-require="emby-button">
        <div data-role="content">
            <div class="content-primary">
                <h1>ThePornDB</h1>
                <form id="ThePornDBConfigForm">
                    <div class="inputContainer">
                        <label class="inputLabel inputLabelUnfocused" for="MetadataAPIToken">Token</label>
                        <input id="MetadataAPIToken" name="MetadataAPIToken" type="password" is="emby-input" />
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="UseFilePath" name="UseFilePath" type="checkbox" is="emby-checkbox" />
                            <span>Use FilePath for matching</span>
                        </label>
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="UseOSHash" name="UseOSHash" type="checkbox" is="emby-checkbox" />
                            <span>Use OpenSubtitlesHash for matching</span>
                        </label>
                    </div>
                    <div class="selectContainer">
                        <label class="selectLabel" for="OrderStyle">Order Style</label>
                        <select is="emby-select" id="OrderStyle" name="OrderStyle" class="emby-select-withcolor emby-select">
                            <option value="Default">Default</option>
                            <option value="DistanceByTitle">DistanceByTitle</option>
                        </select>
                    </div>
                    <div class="selectContainer">
                        <label class="selectLabel" for="TagStyle">Tag Style</label>
                        <select is="emby-select" id="TagStyle" name="TagStyle" class="emby-select-withcolor emby-select">
                            <option value="Genre">Genre</option>
                            <option value="Tag">Tag</option>
                            <option value="Disabled">Disabled</option>
                        </select>
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="AddCollectionOnSite" name="AddCollectionOnSite" type="checkbox" is="emby-checkbox" />
                            <span>Add Collection on Site</span>
                        </label>
                    </div>
                    <div class="inputContainer">
                        <label class="inputLabel inputLabelUnfocused" for="CollectionMinSize">CollectionMinSize</label>
                        <input id="CollectionMinSize" name="CollectionMinSize" type="number" is="emby-input" min="0" />
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="AddCollectionToCollections" name="AddCollectionToCollections" type="checkbox" is="emby-checkbox" />
                            <span>Add Collection to Collections</span>
                        </label>
                    </div>
                    <div class="selectContainer">
                        <label class="selectLabel" for="CollectionType">Collection Type</label>
                        <select is="emby-select" id="CollectionType" name="CollectionType" class="emby-select-withcolor emby-select">
                            <option value="All">All</option>
                            <option value="Scene">Scene</option>
                            <option value="Movie">Movie</option>
                            <option value="JAV">JAV</option>
                        </select>
                    </div>
                    <div class="selectContainer">
                        <label class="selectLabel" for="StudioStyle">Studio Style</label>
                        <select is="emby-select" id="StudioStyle" name="StudioStyle" class="emby-select-withcolor emby-select">
                            <option value="Site">Site</option>
                            <option value="Parent">Parent</option>
                            <option value="Network">Network</option>
                            <option value="All">All</option>
                        </select>
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="UseCustomTitle" name="UseCustomTitle" type="checkbox" is="emby-checkbox" />
                            <span>Use Custom Title Format</span>
                        </label>
                    </div>
                    <div class="inputContainer">
                        <label class="inputLabel inputLabelUnfocused" for="CustomTitle">Custom Title Format</label>
                        <input id="CustomTitle" name="CustomTitle" type="text" is="emby-input" />
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="UseUnmatchedTag" name="UseUnmatchedTag" type="checkbox" is="emby-checkbox" />
                            <span>Use Unmatched Tag</span>
                        </label>
                    </div>
                    <div class="inputContainer">
                        <label class="inputLabel inputLabelUnfocused" for="UnmatchedTag">Unmatched Tag</label>
                        <input id="UnmatchedTag" name="UnmatchedTag" type="text" is="emby-input" />
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="DisableMediaAutoIdentify" name="DisableMediaAutoIdentify" type="checkbox" is="emby-checkbox" />
                            <span>Disable Media Auto Identify</span>
                        </label>
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="DisableActorsAutoIdentify" name="DisableActorsAutoIdentify" type="checkbox" is="emby-checkbox" />
                            <span>Disable Actors Auto Identify</span>
                        </label>
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="DisableMaleActors" name="DisableMaleActors" type="checkbox" is="emby-checkbox" />
                            <span>Disable Male Actors</span>
                        </label>
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="DisableActors" name="DisableActors" type="checkbox" is="emby-checkbox" />
                            <span>Disable Actors Saving to Metadata</span>
                        </label>
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="DisableGenres" name="DisableGenres" type="checkbox" is="emby-checkbox" />
                            <span>Disable Genres Saving to Metadata</span>
                        </label>
                    </div>
                    <div class="selectContainer">
                        <label class="selectLabel" for="ScenesImage">Scenes Image Option</label>
                        <select is="emby-select" id="ScenesImage" name="ScenesImage" class="emby-select-withcolor emby-select">
                            <option value="Poster">Poster</option>
                            <option value="Background">Background</option>
                        </select>
                    </div>
                    <div class="checkboxContainer checkboxContainer-withDescripton">
                        <label class="emby-checkbox-label">
                            <input id="AddDisambiguation" name="AddDisambiguation" type="checkbox" is="emby-checkbox" />
                            <span>Add Disambiguation to Performer Name</span>
                        </label>
                    </div>
                    <div class="selectContainer">
                        <label class="selectLabel" for="ActorsRole">Actors Role Option</label>
                        <select is="emby-select" id="ActorsRole" name="ActorsRole" class="emby-select-withcolor emby-select">
                            <option value="None">None</option>
                            <option value="Gender">Gender</option>
                            <option value="NameByScene">Name from Scene</option>
                        </select>
                    </div>
                    <div class="selectContainer">
                        <label class="selectLabel" for="ActorsImage">Actors Image Option</label>
                        <select is="emby-select" id="ActorsImage" name="ActorsImage" class="emby-select-withcolor emby-select">
                            <option value="Poster">Poster</option>
                            <option value="Face">Face</option>
                        </select>
                    </div>
                    <div class="selectContainer">
                        <label class="selectLabel" for="ActorsOverview">Actors Overview Option</label>
                        <select is="emby-select" id="ActorsOverview" name="ActorsOverview" class="emby-select-withcolor emby-select">
                            <option value="None">None</option>
                            <option value="Default">Default</option>
                            <option value="CustomExtras">Custom Extras</option>
                        </select>
                    </div>
                    <div class="inputContainer">
                        <label class="inputLabel inputLabelUnfocused" for="ActorsOverviewFormat">Actor Custom Format</label>
                        <textarea is="emby-textarea" id="ActorsOverviewFormat" class="textarea-mono emby-textarea" rows="9" style="overflow-y: hidden; height: 90px; width: 100%;">
                        </textarea>
                    </div>
                    <button is="emby-button" type="submit" class="raised button-submit block emby-button">
                        <span>Save</span>
                    </button>
                </form>
            </div>
        </div>
        <script type="text/javascript">
            var ThePornDBConfig = {
                pluginUniqueId: 'fb7580cf-576d-4991-8e56-0b4520c111d3'
            };

            $('#ThePornDBConfigurationPage').on('pageshow', function () {
                Dashboard.showLoadingMsg();
                ApiClient.getPluginConfiguration(ThePornDBConfig.pluginUniqueId).then(function (config) {
                    $('#MetadataAPIToken').val(config.MetadataAPIToken).change();
                    $('#UseFilePath').prop('checked', config.UseFilePath);
                    $('#UseOSHash').prop('checked', config.UseOSHash);
                    $('#OrderStyle').val(config.OrderStyle).change();
                    $('#TagStyle').val(config.TagStyle).change();
                    $('#AddCollectionOnSite').prop('checked', config.AddCollectionOnSite);
                    $('#CollectionMinSize').val(config.CollectionMinSize).change();
                    $('#AddCollectionToCollections').prop('checked', config.AddCollectionToCollections);
                    $('#CollectionType').val(config.CollectionType).change();
                    $('#StudioStyle').val(config.StudioStyle).change();
                    $('#UseCustomTitle').prop('checked', config.UseCustomTitle);
                    $('#CustomTitle').val(config.CustomTitle).change();
                    $('#UseUnmatchedTag').prop('checked', config.UseUnmatchedTag);
                    $('#UnmatchedTag').val(config.UnmatchedTag).change();
                    $('#DisableMediaAutoIdentify').prop('checked', config.DisableMediaAutoIdentify)
                    $('#DisableActorsAutoIdentify').prop('checked', config.DisableActorsAutoIdentify);
                    $('#DisableMaleActors').prop('checked', config.DisableMaleActors);
                    $('#DisableActors').prop('checked', config.DisableActors);
                    $('#DisableGenres').prop('checked', config.DisableActors);
                    $('#ScenesImage').val(config.ScenesImage).change();
                    $('#AddDisambiguation').prop('checked', config.AddDisambiguation);
                    $('#ActorsRole').val(config.ActorsRole).change();
                    $('#ActorsImage').val(config.ActorsImage).change();
                    $('#ActorsOverview').val(config.ActorsOverview).change();
                    $('#ActorsOverviewFormat').val(config.ActorsOverviewFormat).change();
                    Dashboard.hideLoadingMsg();
                });
            });

            $('#ThePornDBConfigForm').on('submit', function () {
                Dashboard.showLoadingMsg();
                ApiClient.getPluginConfiguration(ThePornDBConfig.pluginUniqueId).then(function (config) {
                    config.MetadataAPIToken = $('#MetadataAPIToken').val();
                    config.UseFilePath = $('#UseFilePath').prop('checked');
                    config.UseOSHash = $('#UseOSHash').prop('checked');
                    config.OrderStyle = $('#OrderStyle').val();
                    config.TagStyle = $('#TagStyle').val();
                    config.AddCollectionOnSite = $('#AddCollectionOnSite').prop('checked');
                    config.CollectionMinSize = $('#CollectionMinSize').val();
                    config.AddCollectionToCollections = $('#AddCollectionToCollections').prop('checked');
                    config.CollectionType = $('#CollectionType').val();
                    config.StudioStyle = $('#StudioStyle').val();
                    config.UseCustomTitle = $('#UseCustomTitle').prop('checked');
                    config.CustomTitle = $('#CustomTitle').val();
                    config.UseUnmatchedTag = $('#UseUnmatchedTag').prop('checked');
                    config.UnmatchedTag = $('#UnmatchedTag').val();
                    config.DisableMediaAutoIdentify = $('#DisableMediaAutoIdentify').prop('checked');
                    config.DisableActorsAutoIdentify = $('#DisableActorsAutoIdentify').prop('checked');
                    config.DisableMaleActors = $('#DisableMaleActors').prop('checked');
                    config.DisableActors = $('#DisableActors').prop('checked');
                    config.DisableGenres = $('#DisableGenres').prop('checked');
                    config.ScenesImage = $('#ScenesImage').val();
                    config.AddDisambiguation = $('#AddDisambiguation').prop('checked');
                    config.ActorsRole = $('#ActorsRole').val();
                    config.ActorsImage = $('#ActorsImage').val();
                    config.ActorsOverview = $('#ActorsOverview').val();
                    config.ActorsOverviewFormat = $('#ActorsOverviewFormat').val()
                    ApiClient.updatePluginConfiguration(ThePornDBConfig.pluginUniqueId, config).then(function (result) {
                        Dashboard.processPluginConfigurationUpdateResult(result);
                    });
                });
                return false;
            });
        </script>
    </div>
</body>
</html>
